%% test when patterns in a case construct contains variables bound before it
-include_lib("ect/include/ect.hrl").

-module(clause_boundvars).

-import_class(pattern1).

-export([dotest/0]).

dotest() ->
    dotest0({b, bound}, #pattern1{a = pass, b = bound}).

dotest0(Z, Class) ->
    fun({a, X}) ->
        A = X, A;
       ({b, X}) ->
        A = X, A
    end,
    case Z of
    {a, X} ->
        B = X, B;
    {b, X} ->
        B = X, B
    end,
    case Class of
    #pattern1{c = B} ->
        halal;
    #pattern1{a = A, b = B} ->
        A;
    _ ->
        toobad
    end.